#ifndef __CONFIGURATION_H__
#define __CONFIGURATION_H__

#include <pthread.h>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include "../log/Logger.hpp"
using std::cout;
using std::endl;

class Configuration {
   private:
    static Configuration* _pInstance;               // 单例对象的指针
    static pthread_once_t _once;                    // 线程安全
    static std::string _filepath;                   // 配置文件路径
    std::map<std::string, std::string> _configMap;  // 配置问价内容解析后的map
    std::set<std::string> _englishStopWordList;  // 英文停用词set集合
    std::set<std::string> _chineseStopWordList;  // 中文停用词set集合

   public:
    static void init();
    static void destroy();

    static Configuration& getInstance();

    std::map<std::string, std::string>& getConfigMap();
    std::set<std::string>& getEnglishStopWordList();
    std::set<std::string>& getChineseStopWordList();

    // 下述为模块二对配置文件中配置项的的get函数
    std::string getWebXmlPath();
    std::string getFormatedWebPagePath();
    std::string getOffsetFilePath();
    std::string getInvertIndxPath();
    int getSimhashTopk();
    int getSimhashEqualFlag();

    //读取mysql相关信息
    std::string getMysqlIp();
    std::string getMysqlUsername();
    std::string getMysqlPassword();
    std::string getMysqlDbname();
    std::string getMysqlPort();
    std::string getMysqlMinsize();
    std::string getMysqlMaxsize();
    std::string getMysqlTimeout();
    std::string getMysqlMaxIdleTime();


   private:
    Configuration();
    ~Configuration();
    void readConfigFile();
    void readEnglishStopWordFile();
    void readChineseStopWordFile();
};

#endif
